package com.deyou.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.deyou.R;
import com.deyou.model.MsgBean;
import com.deyou.widget.CircleImageView;
import com.zhy.autolayout.utils.AutoUtils;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by yangyuancheng on 2017/6/14.
 */

public class NotifyListAdapter extends BaseQuickAdapter<MsgBean, NotifyListAdapter.MsgViewHolder> {
    private int msgType; // 1-消息 2-提醒
    private Context mContext;

    public void setMsgType(int msgType) {
        this.msgType = msgType;
    }

    public NotifyListAdapter(Context context) {
        super(R.layout.msg_item_layout);
        this.mContext = context;
    }

    @Override
    protected void convert(MsgViewHolder helper, MsgBean item) {
        if (msgType == 1){
            helper.tvMsgContent.setVisibility(View.VISIBLE);
            helper.tvNotifyContent.setVisibility(View.GONE);
        } else {
            helper.tvMsgContent.setVisibility(View.GONE);
            helper.tvNotifyContent.setVisibility(View.VISIBLE);
        }
    }

    static class MsgViewHolder extends BaseViewHolder {
        @BindView(R.id.msg_type_photo)
        CircleImageView msgTypePhoto;
        @BindView(R.id.tv_msg_from)
        TextView tvMsgFrom;
        @BindView(R.id.tv_msg_send_time)
        TextView tvMsgSendTime;
        @BindView(R.id.tv_msg_content)
        TextView tvMsgContent;
        @BindView(R.id.tv_notify_content)
        TextView tvNotifyContent;

        MsgViewHolder(View view) {
            super(view);
            AutoUtils.auto(view);
            ButterKnife.bind(this, view);
        }
    }
}
